home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Adobe Graphics & Publishing SDK 1996 December
/
Adobe Graphics & Publishing SDK 1996 December.iso
/
mac
/
Photoshop 4.0 SDK r2 Mac
/
Examples
/
Selection
/
Selectorama
/
SelectoramaUIMac.c
< prev
Wrap
Text File
|
1996-09-13
|
5KB
|
188 lines
/*
File: SelectoramaUIMac.c
Copyright 1996 by Adobe Systems, Inc.
C source file for Mac specific code for Selection example.
*/
#include "Selectorama.h"
#include "DialogUtilities.h"
/*****************************************************************************/
/* Displays the about dialog box for the plug-in module. */
void DoAbout (GPtr globals)
{
ShowAbout(gStuff->hostSig, AboutID);
}
/*****************************************************************************/
/* Setup the parameters dialog. Returns TRUE if it succeeds. */
Boolean DoParameters (GPtr globals)
{
short item, lastitem;
short lastArea = gWhatArea;
short lastChannels = gWhatChannels;
short lastPercent = gPercent;
short numberErr = noErr;
long x;
DialogPtr dp;
DialogTHndl dialogHdl;
dialogHdl = (DialogTHndl) GetResource ('DLOG', uiID);
if (dialogHdl == NULL || *dialogHdl == NULL)
return false;
else
{
HNoPurge ((Handle) dialogHdl);
CenterDialog (dialogHdl);
SetUpMoveableModal (dialogHdl, gStuff->hostSig);
dp = GetNewDialog (uiID, nil, (WindowPtr) -1);
/* I am throwing away the results from these routines.
Toolbox TechNote 37 does not document what error values they return.
Also, the worst that happens is that the interface isn't quite right. */
(void) SetDialogDefaultItem (dp, ok);
(void) SetDialogCancelItem (dp, cancel);
(void) SetDialogTracksCursor (dp, TRUE);
SetRadioGroupState (dp,
kFirstItem,
kLastItem,
kFirstItem + gWhatArea);
SetRadioGroupState (dp,
kUseRadio1,
kUseRadioLast,
kUseRadio1 + gWhatChannels);
SetRadioGroupState (dp,
kCreateRadio1,
kCreateRadioLast,
kCreateRadio1 + gCreate);
ShowHideItem (dp, kPercentStatic, (gWhatArea == iSelectRandom));
ShowHideItem (dp, kPercentEdit, (gWhatArea == iSelectRandom));
ShowHideItem (dp, kPercentSymbol, (gWhatArea == iSelectRandom));
StuffNumber(dp, kPercentEdit, gPercent);
if (gWhatArea == iSelectRandom) SelectTextItem(dp, kPercentEdit);
SelectWindow (dp);
do
{
MoveableModalDialog (dp, gStuff->processEvent, nil, &item);
if (lastitem != item && item != cancel)
{ /* we just left this area. Check to make sure its within bounds. */
switch (lastitem)
{
case kPercentEdit:
numberErr = FetchNumber(dp,
kPercentEdit,
kPercentMin,
kPercentMax,
&x);
if (numberErr != noErr)
{ // shows alert if there's an error
AlertNumber(dp,
kPercentEdit,
kPercentMin,
kPercentMax,
&x,
hDllInstance,
AlertID,
numberErr);
item = kPercentEdit; // stay here
}
gPercent = x;
break;
}
}
switch (item)
{
case ok:
gWhatArea = GetRadioGroupState(dp, kFirstItem, kLastItem) - kFirstItem;
gWhatChannels = GetRadioGroupState(dp, kUseRadio1, kUseRadioLast) - kUseRadio1;
gCreate = GetRadioGroupState(dp, kCreateRadio1, kCreateRadioLast) - kCreateRadio1;
if (gWhatArea == iSelectRandom)
{
numberErr = FetchNumber(dp,
kPercentEdit,
kPercentMin,
kPercentMax,
&x);
if (numberErr != noErr)
{ // shows alert if there's an error
AlertNumber(dp,
kPercentEdit,
kPercentMin,
kPercentMax,
&x,
hDllInstance,
AlertID,
numberErr);
item = kPercentEdit; // go back
}
else gPercent = x; // it's okay, move on
}
break;
case cancel:
gResult = userCanceledErr;
break;
case kPercentEdit:
// grab the number whether it's right or not
numberErr = FetchNumber(dp, kPercentEdit, kPercentMin, kPercentMax, &x);
if (numberErr == noErr)
{ // no errors getting the number
gPercent = x;
// update display here
}
break;
default:
if (item >= kFirstItem && item <= kLastItem)
{
SetRadioGroupState (dp, kFirstItem, kLastItem, item);
ShowHideItem (dp, kPercentStatic, (item == iSelectRandom + kFirstItem));
ShowHideItem (dp, kPercentEdit, (item == iSelectRandom + kFirstItem));
ShowHideItem (dp, kPercentSymbol, (item == iSelectRandom + kFirstItem));
if (item == iSelectRandom + kFirstItem) SelectTextItem(dp, kPercentEdit);
}
else if (item >= kUseRadio1 && item <= kUseRadioLast)
SetRadioGroupState (dp, kUseRadio1, kUseRadioLast, item);
else if (item >= kCreateRadio1 && item <= kCreateRadioLast)
SetRadioGroupState (dp, kCreateRadio1, kCreateRadioLast, item);
break;
}
lastitem = item;
}
while (item != ok && item != cancel);
DisposDialog (dp);
if (dialogHdl != NULL && *dialogHdl != NULL)
HPurge ((Handle) dialogHdl);
dp = NULL;
dialogHdl = NULL;
return item == ok;
} // else
}
/*********************************************************************/